﻿/// <reference name="MicrosoftAjax.debug.js" />
/// <reference path="../../Resources/js/jquery/jquery.debug.js" />


Type.registerNamespace("BM");

// TitleAddition object

BM.TitleAddition = function(item, additionNode) {
    BM.TitleAddition.initializeBase(this, [item, additionNode]);    
}

BM.TitleAddition.prototype = {
    load: function() {
        BM.TitleAddition.callBaseMethod(this, 'load');
        this.getItem().addDescriptionChanged(Function.createDelegate(this, this.descriptionChanged));        
    },

    descriptionChanged: function() {
        this.setTitleText(this.getItem().getDescription());
    },

    setTitleText: function(text) {
        this.getTitleTextNode().nodeValue = text;
    },

    getTitleTextNode: function() {
        return $(this.getItem().getNode()).children('.Title').children('.Content').contents().filter(function() { return this.nodeType == 3; })[0];
    }
}

BM.Addition['TitleAddition'] = BM.TitleAddition;
BM.TitleAddition.registerClass("BM.TitleAddition", BM.Addition);